﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using QuickApp.Core;
using Resto.CostControl.Core;
using QuickApp.MVCControl;

namespace Resto.CostControl.Web.Controllers
{
    public class OrderViewController : Controller
    {
        private readonly IRepository<OrderMaterial> _RepoOM;
        private readonly IRepository<OrderReported> _RepoOR;
        private readonly IRepository<OrderDish> _RepoOD;

        public OrderViewController(IRepository<OrderMaterial> repoOM,
            IRepository<OrderReported> repoOR,
            IRepository<OrderDish> repoOD
            )
        {
            _RepoOM = repoOM;
            _RepoOR = repoOR;
            _RepoOD = repoOD;
        }

        public ActionResult OrderMaterialList()
        {
            return View();
        }

        [HttpPost]
        public JsonResult OrderMaterialList(DWZPageInfo pager, DWZQueryModel where)
        {
            var list = _RepoOM.GetPageable(pager.ToPageInfo(), where);
            var fdata = pager.ToFlexiGridData<OrderMaterial>(list.Page.ToList(), list.Total);

            return Json(fdata);
        }

        public ActionResult OrderReportedList()
        {
            return View();
        }

        [HttpPost]
        public JsonResult OrderReportedList(DWZPageInfo pager, DWZQueryModel where)
        {
            var list = _RepoOR.GetPageable(pager.ToPageInfo(), where);
            var fdata = pager.ToFlexiGridData<OrderReported>(list.Page.ToList(), list.Total);

            return Json(fdata);
        }

        public ActionResult OrderDishList()
        {
            return View();
        }

        [HttpPost]
        public JsonResult OrderDishList(DWZPageInfo pager, DWZQueryModel where)
        {
            var list = _RepoOD.GetPageable(pager.ToPageInfo(), where);
            var fdata = pager.ToFlexiGridData<OrderDish>(list.Page.ToList(), list.Total);

            return Json(fdata);
        }

    }
}
